#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int N = 31;

int preorder[N], pre;
int inorder[N], in;
int postorder[N], idx;
int n;


void post_order(int u, int s, int e) {
    if (s > e) return ;
    int i = s;
    while (i < e && inorder[i] != preorder[u]) i ++ ;
    post_order(u + 1, s, i - 1);
    post_order(u + 1 + i - s, i + 1, e);
    postorder[idx ++ ] = inorder[i];
}

inline void solution() {
    scanf("%d\n", &n);
    int cnt = n * 2;
    stack<int> stk;
    while (cnt -- ) {
        string s;
        getline(cin, s);
        if (s[1] == 'u') {
            int num = stoi(s.substr(5));
            stk.push(num);
            preorder[pre ++ ] = num;
        } else {
            int num = stk.top(); stk.pop();
            inorder[in ++ ] = num;
        }
    }

    post_order(0, 0, n - 1);

    cout << postorder[0];
    for (int i = 1; i < n; i ++ ) 
        cout << " " << postorder[i];
    cout << endl;
}

int main() {
    freopen("input.txt", "r", stdin);
    // quickread();
    solution();
    return 0;
}